// 使用指针和switch

#include <iostream>
using namespace std;

int main() {
    int number;
    int* p_number = &number;

    cout << "请输入一个整数: ";

    // 通过指针间接输入
    cin >> *p_number;

    cout << "He Played knick-knack ";

    // 等价于if else语句
    switch (number) {
        case 1:
            cout << "with his thumb.\n";
            // 不要漏了break,否则会执行到下面，直到遇到break为止
            break;

        case 2:
            cout << "with my shoe.\n";
            break;

        case 3:
            cout << "on his knee.\n";
            break;

        case 4:
            cout << "at the door.\n";
            break;

        default:
            cout << "\nWhoa! He doesn't play knick-knack there!\n";
            break;
    }
}

// src="ch04/3_8.cpp"; [ "$src" -nt a.out ] && g++ -m32 -O1 "$src"; ./a.out


